//TODO SG restore if required
//package com.magenta.maxoptra.gis.distancematrix.iterators;
//
//import com.magenta.commons.structure.Pair;
//import com.magenta.maxoptra.gis.GeographicCoordinates;
//import com.magenta.maxoptra.gis.distancematrix.DistanceMatrixCoordinate;
//import com.magenta.maxoptra.gis.distancematrix.RoutesIterator;
//import org.jetbrains.annotations.Nullable;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
///**
// * @author Sergey Grachev
// */
//public final class SymmetricIterator implements RoutesIterator {
//
//    private final List<DistanceMatrixCoordinate> coordinates;
//    private boolean forward = true;
//    private int matrixY = 0;
//    private int matrixX = 1;
//
//    public SymmetricIterator(final List<? extends DistanceMatrixCoordinate> coordinates) {
//        this.coordinates = new ArrayList<DistanceMatrixCoordinate>(coordinates);
//    }
//
//    @Nullable
//    @Override
//    public Pair<DistanceMatrixCoordinate, DistanceMatrixCoordinate> next() {
//        if (!hasNext()) {
//            return null;
//        }
//
//        doNextStep();
//
//        final Pair<DistanceMatrixCoordinate, DistanceMatrixCoordinate> route =
//                new Pair<DistanceMatrixCoordinate, DistanceMatrixCoordinate>(coordinates.get(matrixY), coordinates.get(matrixX));
//
//        if (forward) {
//            matrixX++;
//        } else {
//            matrixY++;
//        }
//
//        return route;
//    }
//
//    @Nullable
//    @Override
//    public Pair<DistanceMatrixCoordinate, List<DistanceMatrixCoordinate>> nextMatrix(final int coordinatesLimit) {
////        if (!hasNext()) {
////            return null;
////        }
////
////        doNextStep();
////
////        final GeographicCoordinates origin = coordinates.get(forward ? matrixY : matrixX);
////        final List<GeographicCoordinates> destinations = new ArrayList<GeographicCoordinates>();
////        for (int i = forward ? matrixX : matrixY; i < coordinates.size(); i++) {
////            destinations.add(coordinates.get(i));
////            if (forward) {
////                matrixX++;
////            } else {
////                matrixY++;
////            }
////        }
////
////        return new Pair<GeographicCoordinates, List<GeographicCoordinates>>(origin, destinations);
//        throw new UnsupportedOperationException("Method not supported");
//    }
//
//    private void doNextStep() {
//        if (forward) {
//            if (matrixX >= coordinates.size()) {
//                //noinspection SuspiciousNameCombination
//                matrixX = matrixY;
//                matrixY = matrixY + 1;
//                forward = false;
//            }
//        } else {
//            if (matrixY >= coordinates.size()) {
//                matrixY = matrixX + 1;
//                matrixX = matrixY + 1;
//                forward = true;
//            }
//        }
//    }
//
//    @Override
//    public boolean hasNext() {
//        return coordinates.size() > 1 && (forward || matrixX + 2 < coordinates.size());
//    }
//
//    @Override
//    public boolean isFullCycleForRoute() {
//        return !forward && matrixY >= coordinates.size();
//    }
//
//    @Override
//    public List<DistanceMatrixCoordinate> getFinishedCycleFor() {
//        if (isFullCycleForRoute()) {
//            return hasNext()
//                    ? Arrays.asList(coordinates.get(matrixX))
//                    : Arrays.asList(coordinates.get(matrixX), coordinates.get(coordinates.size() - 1));
//        }
//        return null;
//    }
//
//    @Override
//    public State getFinishedState() {
//        return null;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//}
